package com.lee.learndrools;

import com.lee.learndrools.pojo.Person;
import com.lee.learndrools.pojo.School;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

/**
 * @author liylw
 * @date 2021/9/14 19:24
 */
public class RulesHello {

    public static void main(String[] args) {
        final KieServices kss = KieServices.Factory.get();
        final KieContainer kc = kss.getKieClasspathContainer();
        final KieSession ks = kc.newKieSession("memberOf");
        final Person person = new Person();
        person.setAge(30);
        person.setName("张三");
        person.setClassName("一班");
        ks.insert(person);

        final School school = new School();
        school.setClassName("一班");
        school.setClassNameArray(new String[]{"一班","二班","三班"});
        ks.insert(school);
        final int count = ks.fireAllRules();
        System.out.println("一共执行了："+count);
        System.out.println("年龄修改为："+person.getAge());
        ks.dispose();
    }


}
